package redis

import "strconv"

// 同步redis 虚拟库存
func SyncGoodsStock(goodsID, goodsStock int) {
	key := "goods_id_" + strconv.Itoa(goodsID) //goods_id_6

	for i := 0; i < goodsStock; i++ {
		RedisDB.RPush(key, goodsID)
	}

}

// 获取虚拟库存
func GetGoodsStock(goodsID int) (goodsStock int) {
	key := "goods_id_" + strconv.Itoa(goodsID)
	goodsStock = int(RedisDB.LLen(key).Val())

	return goodsStock
}
